<?php
if (!defined('IN_XLP')) {
        exit('Access Denied');
}
$Document = array(
  'pageid' => 'guess-index', //页面标示
  'pagename' => '疯狂猜图列表', //当前页面名称
  'mycss' => array(), //加载的css样式表
  'myjs' => array(), //加载的js脚本
  'footerjs' => array('content/jquery.smoothConfirm', 'content/calendar'),
  'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public'); ?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public'); ?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->

<section id="content"> 
        <!-- main padder -->
        <section class="main padder">
                <div class="clearfix">
                        <h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'], '_'); ?></h4>
                </div>
                <div class="row"> 

                        <!-- table 11 -->
                        <div class="col-lg-12">
                                <section class="panel">
                                        <!---->
                                        <div class="panel-body">
                                                <div class="row text-small">
                                                        <div class="col-sm-3">
                                                                <a class="btn btn-default" href="<?php echo U('guess/add'); ?>">添加题目</a>
                                                                <div class="btn-group">
                                                                        <a class="btn btn-default" href="<?php echo U('guess/set'); ?>">栏目设置</a>
                                                                </div>
                                                                <a class="btn btn-default" rel="pop" href="<?php echo U('guess/countinfo'); ?>">统计</a>
                                                        </div>
                                                        <div class="col-sm-4">
                                                                <h4><span class="label bg-primary"><i class="fa fa-bell-o"></i>提示：</span>
                                                                        有<span class="badge bg-primary"><?php echo $verifyNo ? $verifyNo : 0; ?></span>道题处于未审核状态 
                                                                        请及时处理
                                                                </h4> 

                                                        </div>
                                                        <div class="col-sm-5">
                                                                <form action="<?php echo U(ACTION_NAME . '/index'); ?>" method="get" name="form1" target="_self">
                                                                        <div class="col-sm-7 m-b-mini">
                                                                                <div class="form-group">
                                                                                        <?php if (isHave($q)) { ?>
                                                                                                <p>搜索关键字为：<span class="red"><?php echo $q; ?></span></p>
                                                                                        <?php } ?>
                                                                                </div>
                                                                        </div>
                                                                        <div class="col-sm-5 input-group">
                                                                                <input type="text" name="q" class="input-sm form-control" placeholder="请输入搜索关键字..." />
                                                                                <input name="g" type="hidden" value="<?php echo GROUP_NAME; ?>" />
                                                                                <input name="c" type="hidden" value="<?php echo ACTION_NAME; ?>" />
                                                                                <input name="m" type="hidden" value="<?php echo MODEL_NAME; ?>" />
                                                                                <span class="input-group-btn">
                                                                                        <button class="btn btn-sm btn-white" type="submit">搜索</button>
                                                                                </span> </div>
                                                                </form>
                                                        </div>
                                                </div>
                                        </div>
                                        <!---->
                                        <div class="table-responsive">
                                                <table class="table table-striped b-t text-small">
                                                        <thead>
                                                                <tr>
                                                                        <th align="center">ID</th>
                                                                        <th align="center">标题</th>
                                                                        <th align="center">封面</th>
                                                                        <th align="center">
                                                        <div class="select filter " data-resize="auto"> 
                                                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                                                        <i class="fa fa-cog fa-lg visible-xs visible-xs-inline"></i>困难程度 <b class="caret hidden-sm-only"></b></a>
                                                                <ul class="dropdown-menu"> 
                                                                        <li data-value="all" data-selected="true">
                                                                                <a href="<?php echo U('guess/index', array('diff' => 'all', 'sour' => $sour, 'sta' => $sta, 'ver' => $ver)); ?>">全部</a></li> 
                                                                        <li data-value="lt5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => 1, 'sour' => $sour, 'sta' => $sta, 'ver' => $ver)); ?>"><?php echo $difficulty[1]; ?></a></li> 
                                                                        <li data-value="gte5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => 2, 'sour' => $sour, 'sta' => $sta, 'ver' => $ver)); ?>"><?php echo $difficulty[2]; ?></a></li> 
                                                                </ul> 
                                                        </div> </th>
                                                        <th align="center">
                                                        <div class="select filter " data-resize="auto"> 
                                                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                                                        <i class="fa fa-cog fa-lg visible-xs visible-xs-inline"></i>题目来源 <b class="caret hidden-sm-only"></b></a>
                                                                <ul class="dropdown-menu"> 
                                                                        <li data-value="all" data-selected="true">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => 'all', 'sta' => $sta, 'ver' => $ver)); ?>">全部</a></li> 
                                                                        <li data-value="lt5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => 1, 'sta' => $sta, 'ver' => $ver)); ?>"><?php echo $source[1]; ?></a></li> 
                                                                        <li data-value="gte5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => 2, 'sta' => $sta, 'ver' => $ver)); ?>"><?php echo $source[2]; ?></a></li> 
                                                                </ul> 
                                                        </div> </th>
                                                        <th align="center">回答正确增加积分</th>
                                                        <th align="center">回答错误减少积分</th>
                                                        <th align="center">最后修改时间</th>
                                                        <th align="center">
                                                        <div class="select filter " data-resize="auto"> 
                                                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                                                        <i class="fa fa-cog fa-lg visible-xs visible-xs-inline"></i>上线状态 <b class="caret hidden-sm-only"></b></a>
                                                                <ul class="dropdown-menu"> 
                                                                        <li data-value="all" data-selected="true">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => 'all', 'ver' => $ver)); ?>">全部</a></li> 
                                                                        <li data-value="lt5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => 1, 'ver' => $ver)); ?>"><?php echo $status[1]; ?></a></li> 
                                                                        <li data-value="gte5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => 2, 'ver' => $ver)); ?>"><?php echo $status[2]; ?></a></li> 
                                                                </ul> 
                                                        </div> 
                                                        </th>
                                                        <th align="center">
                                                        <div class="select filter " data-resize="auto"> 
                                                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                                                        <i class="fa fa-cog fa-lg visible-xs visible-xs-inline"></i>审核状态 <b class="caret hidden-sm-only"></b></a>
                                                                <ul class="dropdown-menu"> 
                                                                        <li data-value="all" data-selected="true">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => $sta, 'ver' => 'all')); ?>">全部</a></li> 
                                                                        <li data-value="lt5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => $sta, 'ver' => 1)); ?>"><?php echo $verify[1]; ?></a></li> 
                                                                        <li data-value="gte5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => $sta, 'ver' => 2)); ?>"><?php echo $verify[2]; ?></a></li> 
                                                                        <li data-value="gte5m">
                                                                                <a href="<?php echo U('guess/index', array('diff' => $diff, 'sour' => $sour, 'sta' => $sta, 'ver' => 3)); ?>"><?php echo $verify[3]; ?></a></li> 
                                                                </ul> 
                                                        </div> 
                                                        </th>
                                                        <th align="center">操作</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                                <?php
                                                                if ($rs) {
                                                                        foreach ($rs as $val) {
                                                                                ?>
                                                                                <tr id="list_detail_<?php echo $val['id']; ?>">
                                                                                        <td><?php echo $val['id']; ?></td>
                                                                                        <td><a title="点击查看详情信息" rel="pop" href="<?php echo U('guess/getinfo',array('id'=>$val['id']));?>" ><?php echo $val['title']; ?></a></td>
                                                                                        <td><a title="点击查看图片大图" rel="pop" href="<?php echo getImgUrl($val['pic']); ?>" ><img  style="width: 50px; height: 50px;" src='<?php echo getImgUrl($val['pic']); ?>'  ></a></td>
                                                                                        <td><?php echo $difficulty[$val['difficulty']]; ?></td>
                                                                                        <td><?php echo $source[$val['source']]; ?></td>
                                                                                        <td><?php echo $val['credit_add']; ?></td>
                                                                                        <td><?php echo $val['credit_del']; ?></td>
                                                                                        <td><?php echo ($val['infotime'] ? outTime($val['infotime']) : ''); ?></td>   
                                                                                        <td id="status_<?php echo $val['id']; ?>"><?php echo $status[$val['status']]; ?></td> 
                                                                                        <td id="verify_<?php echo $val['id']; ?>"><?php echo $verify[$val['verify']]; ?></td> 
                                                                                        <td><div class="btn-group">
                                                                                                        <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button>
                                                                                                        <ul class="dropdown-menu">
                                                                                                                <li><a href="javascript:;" rel="<?php echo $val['id']; ?>" key="1"  class="deal">上线处理</a></li>
                                                                                                                <li><a href="javascript:;" rel="<?php echo $val['id']; ?>" key="2"  class="deal">审核处理</a></li>
                                                                                                                <?php if (isHave($val['user_id'])) { ?>
                                                                                                                  <li class="divider"></li>
                                                                                                                        <li><a href="<?php echo U('guess/userinfo', array('id' => $val['user_id'])); ?>" rel="pop" class="">用户信息</a></li>
                                                                                                                <?php } ?>
                                                                                                                        <li class="divider"></li>
                                                                                                                <li><a href="<?php echo U('guess/edit', array('id' => $val['id'])); ?>" class="edit">编辑</a></li>
                                                                                                                <li><a href="javascript:;" rel="<?php echo $val['id']; ?>" class="delete">删除</a></li>
                                                                                                        </ul>
                                                                                                </div></td>
                                                                                </tr>
                                                                                <?php
                                                                        }
                                                                } else {
                                                                        ?>
                                                                        <tr>
                                                                                <td colspan="20" align="center">暂无数据</td>
                                                                        </tr>
                                                                        <?php
                                                                }
                                                                ?>
                                                        </tbody>
                                                </table>
                                        </div>
                                        <footer class="panel-footer">
                                                <div class="row">
                                                        <div class="col-sm-12 text-right text-center-sm"> <?php echo page($total, $p, '', 20, 'p'); ?> </div>
                                                </div>
                                        </footer>
                                </section>
                        </div>
                        <!--/ table 11 -->
                </div>
        </section>
        <!--/ main padder --> 
</section>
<!--/ content --> 
<!--主体 结束--> 
<script>
        $(function() {
                $('.deal').click(function() {
                        var id = $(this).attr('rel');
                        var key = $(this).attr('key');
                        //调用smoothConfirm 插件
                        $(this).smoothConfirm("请选择处理方式：", {
                                okVal: key == 1 ? "上线" : "通过",
                                cancelVal: key == 1 ? "下线" : "不通过",
                                //点击确认返回callback
                                ok: function() {
                                        $.getJSON('<?php echo U('guess/deal'); ?>', {"act": "ok", id: id, 'key': key}, function(result) {
                                                if (result.status == 1) {
                                                        if (key == 1) {
                                                                $("#status_" + id).html('<?php echo $status[1]; ?>');
                                                        }
                                                        if (key == 2) {
                                                                $("#verify_" + id).html('<?php echo $verify[1]; ?>');
                                                        }
                                                        if (result.info != 'ok') {
                                                                Msg.alert(result.info);
                                                        }
                                                } else {
                                                        Msg.error(result.info);
                                                }
                                        });
                                },
                                //点击取消返回callback
                                cancel: function() {
                                        $.getJSON('<?php echo U('guess/deal'); ?>', {"act": "invalid", id: id, 'key': key}, function(result) {
                                                if (result.status == 1) {
                                                        if (key == 1) {
                                                                $("#status_" + id).html('<?php echo $status[2]; ?>');
                                                        }
                                                        if (key == 2) {
                                                                $("#verify_" + id).html('<?php echo $verify[2]; ?>');
                                                        }
                                                } else {
                                                        Msg.error(result.info);
                                                }
                                        });
                                }
                        });
                        return false;
                })
                $('.delete').click(function() {
                        var id = $(this).attr('rel');
                        $(this).smoothConfirm("确认删除该条题目吗？", {
                                ok: function() {
                                        $.post('<?php echo U('guess/delete'); ?>', {"id": id}, function(result) {
                                                $("#list_detail_" + id).fadeOut();
                                        }, 'json');
                                },
                                cancel: function() {
                                        return false;
                                }
                        });
                        $("body").click();//取消弹出层对对话框的遮蔽
                        return false;
                })
        })
</script>
<?php
include getTpl('footer', 'public');
?>